<?php
include "../../shared/config.php";
include_once "../../../../php/pear/vendor/autoload.php";
use PhpOffice\PhpWord\TemplateProcessor;

$id = $_GET["id"];
$clan = $_GET["clan"];

if($clan=="zh"){
	$sql = "select * from cv where cv_id = $id";
}
else{
	$sql = "select * from cv_en where cv_id = $id";
}

$data = mysqli_query($conn,$sql);
while($row = mysqli_fetch_array($data, MYSQLI_ASSOC)){
	$name = $row['name'];
	$cv_name = $row['cv_name'];
	$sex = $row['sex'];
	$tel = $row['tel'];
	$email = $row['email'];
	$about = $row['about'];
	$education = $row['education'];
	$job = $row['job'];
	$certification = $row['certification'];

};
$namefile = $cv_name.".docx";
$temp = new TemplateProcessor('../../shared/temp.docx');
$temp->setValue('name',$name);
$temp->setValue('sex',$sex);
$temp->setValue('tel',$tel);
$temp->setValue('email',$email);
$temp->setValue('about',$about);
$temp->setValue('education',$education);
$temp->setValue('job',$job);
$temp->setValue('certification',$certification);
$temp->saveAs($cv_name.".docx");

header("location: $namefile");

?>